package link.luyu.plugin.brochain.web3.methods.response;

import java.math.BigInteger;
import java.util.List;
import org.web3j.utils.Numeric;

public class Log {

    private String address;
    private String data;
    private List<String> topics;

    public Log() {}

    public Log(String address, String data, List<String> topics) {
        this.address = address;
        this.data = data;
        this.topics = topics;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public List<String> getTopics() {
        return topics;
    }

    public void setTopics(List<String> topics) {
        this.topics = topics;
    }

    private BigInteger convert(String value) {
        if (value != null) {
            return Numeric.decodeQuantity(value);
        } else {
            return null;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Log)) {
            return false;
        }

        Log log = (Log) o;
        if (getAddress() != null
                ? !getAddress().equals(log.getAddress())
                : log.getAddress() != null) {
            return false;
        }
        if (getData() != null ? !getData().equals(log.getData()) : log.getData() != null) {
            return false;
        }
        return getTopics() != null ? getTopics().equals(log.getTopics()) : log.getTopics() == null;
    }

    @Override
    public int hashCode() {
        int result = getAddress() != null ? getAddress().hashCode() : 0;
        result = 31 * result + (getData() != null ? getData().hashCode() : 0);
        result = 31 * result + (getTopics() != null ? getTopics().hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Log{"
                + "address='"
                + address
                + '\''
                + ", data='"
                + data
                + '\''
                + ", topics="
                + topics
                + '}';
    }
}
